package com.yonyou.crm.cum.customer.rmimpl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;

import com.alibaba.dubbo.config.annotation.Service;
import com.yonyou.crm.common.page.entity.Page;
import com.yonyou.crm.cum.customer.entity.CustomerFollowVO;
import com.yonyou.crm.cum.customer.entity.CustomerVO;
import com.yonyou.crm.cum.customer.rmitf.IGroupCustomerRmService;
import com.yonyou.crm.cum.customer.service.CustomerFollowBizServiceImpl;
import com.yonyou.crm.cum.customer.service.GroupCustomerBizServiceImpl;
import com.yonyou.crm.sys.dynamic.entity.DynamicVO;

@Service
public class GroupCustomerRmServiceImpl implements IGroupCustomerRmService {

	@Autowired
	private GroupCustomerBizServiceImpl customerService;
	
	@Autowired
	private CustomerFollowBizServiceImpl followService;
	
	@Override
	public CustomerVO getDetail(Long id) {
		CustomerVO customer = customerService.viewDetail(id);
		return customer;
	}

	@Override
	public Page<CustomerVO> getList(Page<CustomerVO> page,
			Map<String, Object> paramMap) {
		Page<CustomerVO> list = customerService.getList(page, paramMap);
		return list;
	}
	
	@Override
	public Map<String, Object> getViewUserList(Long cumId, Map<String, Object> paramMap){
		return customerService.getViewUserList(cumId, paramMap);
	}
	
	@Override
	public Map<String, Object> getFollowUserList(Long cumId, Map<String, Object> paramMap){
		return customerService.getFollowUserList(cumId, paramMap);
	}

	@Override
	public CustomerVO insert(CustomerVO customer) {
		customer = customerService.saveVO(customer);
		return customer;
	}

	@Override
	public CustomerVO update(CustomerVO customer) {
		customer = customerService.updateVO(customer);
		return customer;
	}

	@Override
	public int delete(Long id) {
		int delNum = customerService.delete(id);
		return delNum;
	}

	@Override
	public Page<CustomerVO> batchDelete(String[] ids, Page<CustomerVO> page, Map<String, Object> paraMap) {
		customerService.batchDelete(ids);
		followService.batchDeleteByCumIds(ids);
		return getList(page, paraMap);
	}

	@Override
	public int updateState(Long id, int enableState) {
		return customerService.updateState(id, enableState);
	}
	
	@Override
	public Page<CustomerVO> batchUpdateState(String[] ids, Integer enableState, Page<CustomerVO> page, Map<String, Object> paraMap) {
		customerService.batchUpdateState(ids, enableState);
		return getList(page, paraMap);
	}

	@Override
	public CustomerFollowVO saveFollow(Long cumId) {
		CustomerFollowVO followVO = new CustomerFollowVO();
		followVO.setCumId(cumId);
		
		followVO = followService.insert(followVO);
		return followVO;
	}
	
	@Override
	public int deleteFollow(Long cumId){
		CustomerFollowVO followVO = new CustomerFollowVO();
		followVO.setCumId(cumId);
		
		return followService.delete(followVO);
	}

	@Override
	public int checkNameExist(CustomerVO customer) {
		return customerService.checkNameExist(customer);
	}
	
	@Override
	public int isFollow(Long cumId) {
		return followService.isFollow(cumId);
	}

	@Override
	public List<CustomerVO> getRefList(Map<String, Object> paraMap) {
		return customerService.getRefList(paraMap);
	}
	
	@Override
	public Page<CustomerVO> getRefPage(Page<CustomerVO> page, Map<String, Object> paraMap) {
		return customerService.getRefPage(page, paraMap);
	}
	
	@Override
	public CustomerVO identify(CustomerVO customer){
		return customerService.identify(customer);
	}
	
	@Override
	public CustomerVO cancelIdentify(CustomerVO customer){
		return customerService.cancelIdentify(customer);
	}
	
	@Override
	public boolean getIdentifyFlag(Map<String, Object> paraMap){
		return customerService.getIdentifyFlag(paraMap);
	}
	
	@Override
	public boolean checkVerifyNameExist(String id, String verifyfullname) {
		return customerService.checkVerifyNameExist(id, verifyfullname);
	}

	@Override
	public DynamicVO[] getCumDynamic(Long cumId) {
		return customerService.getCumDynamic(cumId);
	}
}
